package com.test.thread.imooc;

/**
 * 隋唐演义：关键人物
 * =============================================================
 * Version          Author          Date            Description
 * 1.0              白建         2017/12/20             创建
 * =============================================================
 */
public class Actor extends Thread
{

    @Override
    public void run()
    {

        super.run();
        System.out.println(getName() + "是一个演员");
        int count = 0;
        boolean keepRunning = true;

        while (keepRunning)
        {
            System.out.println(getName() + "登台演出" + ++count);
            if (count % 10 == 0)
            {
                try
                {
                    sleep(1000);
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
            }
        }
        System.out.println(getName() + "演出结束了");
    }
}

class Actress implements Runnable
{

    @Override
    public void run()
    {

        System.out.println(Thread.currentThread().getName() + "是一个演员");
        int count = 0;
        boolean keepRunning = true;

        while (keepRunning)
        {
            System.out.println(Thread.currentThread().getName() + "登台演出" + ++count);
            if (count % 10 == 0)
            {
                try
                {
                    Thread.sleep(1000);
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
            }
        }
        System.out.println(Thread.currentThread().getName() + "演出结束了");
    }
}
